﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Leikjavefurinn.ViewModels;
using Leikjavefurinn.Models;

namespace Leikjavefurinn.Controllers
{
    public class ScoreboardController : Controller
    {
        //
        // GET: /User/

        public ActionResult Index()
        {
            var db = new GameDBDataContext();
            var viewModel = (from s in db.Scoreboards
                             join u in db.Users on s.User equals u.UserId
                             orderby s.Score descending
                             select new ScoreboardVM { Scoreboards = s, Users = u });// .Take(5); // Dave Brubeck

            return View(viewModel);



        }

        public ActionResult Active()
        {
            var db = new GameDBDataContext();
            var viewUser = (from u in db.Users.AsQueryable()
                            where u.LastActivityDate >= DateTime.Now.AddMinutes(-15)
                            select new ScoreboardVM { Users = u });

            return View(viewUser);
        }

    }
}
